<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2019/3/12
 * Time: 11:51
 */

namespace app\api\service;
use \app\api\model\MallSetup as MallSetupModel;
use app\common\lib\Redis;
use think\Cache;
use think\Config;

class MallSetup
{
    /**
     * 获取商场设置信息
     * @param $t_id
     * @return array|bool|false|mixed|\PDOStatement|string|\think\Model
     * @throws \think\Exception
     */
    public function getBackInfo($t_id){
        $info = Redis::getInstance()->get(9,'appinfo:mall:t_id:'.$t_id);
        if (!empty($info)){
            return $info;
        }
        $info = MallSetupModel::getMallInfo($t_id);
        Redis::getInstance()->set(9,'appinfo:mall:t_id:'.$t_id,json_encode($info->toArray()),48*3600);
        return $info;
    }
    /**
     * 更新商城信息
     * @param $t_id
     * @param $data
     * @return $this
     */
    public function updateMall($t_id,$data){
        $status = MallSetupModel::updateMall($t_id,$data);
        if($status){
            Redis::getInstance()->del(9,'appinfo:mall:t_id:'.$t_id);//跟新缓存
        }
        return $status;
    }
    /**
     * 获取商城信息
     * @param $t_id
     * @return array|false|\PDOStatement|string|\think\Model
     */
    public function getMallInfo($t_id){
        $info = MallSetupModel::getMallSetByTid($t_id);
        return $info;
    }
    /**
     * 获取商城信息
     * @param $t_id
     * @return array|false|\PDOStatement|string|\think\Model
     */
    public function getMallByAppid($appid){
        $info = MallSetupModel::getMallSetByAppid($appid);
        return $info;
    }
}